The present invention relates to computer database access and, in. particular, to access to a database on one computer by a JAVA applet running on a second computer.
The development of communications networks, personal computers, and client-server network applications has led to frequent access of data stored in database management systems on server computers by application programs running on client computers. Commonly, a client computer establishes a TCP/IP connection to the server computer on which the database management system runs and then sends queries to the database management system and receives responses to those queries via the TCP/IP protocol. The server computer includes a process which listens for TCP/IP connection requests, establishes TCP/IP connections in response to those requests, and establishes connections to the database management system corresponding to the TCP/IP connections. The process forwards incoming queries from client computers through the TCP/IP connections to the corresponding database connections, collects data furnished by the database management system in response to the queries, and forwards the collected data back to the corresponding client computers through the TCP/IP connections.
With the rapid increase in the use of the Internet, web browser applications have become a very common and convenient means for client computer users to access information stored on server computers. Initially, web browsers were capable of retrieving hypertext markup language (xe2x80x9cHTMLxe2x80x9d) documents from a remote server over the Internet and graphically displaying the HTML documents to the web browser user. As web browsers have become more sophisticated, they can now not only receive HTML documents from server computers, but can also receive JAVA programs from server computers and execute the JAVA programs on the client computer under the direction and monitoring of the web browser. These JAVA programs, known as applets, can provide a far more interactive and dynamic display of information than that achieved by displaying static HTML documents. However, JAVA applets give rise to a number of serious administrative and security problems. If the applet was able to have free access to the full range of operating system calls accessed by application programs, then a web browser user could inadvertently download from the Internet a capricious program that disrupts the state of the client computer, including changing the client computer""s configuration settings, that damages or destroys the client computer""s file system and the contents of the client computer""s files, or that rifles the contents of the client computer and transmit those contents back to an even more capricious program running on a server computer. For these reasons, the executing applet is closely guarded and monitored by the web browser, and its access to client and server resources is severely restricted.
It has become very desirable for JAVA applet developers to be able to write applets that can access database information from server computers. FIG. 1 displays a stock price quoting system implemented using a JAVA applet. This stock price quoting system demonstrates both the need for access to server database management systems by a JAVA applet and the problems that currently make such access difficult to achieve. The stock price quoting system displays a list of stocks and prices 101 on a display monitor 102 of a personal computer 103. The processes executing on the personal computer include the operating system 104, a browser 105, and the JAVA applet executing under control of the browser 106 that acquires the stock prices and directs their display. The stock prices are stored on a data storage device 107 managed by a database management system 108 on a server computer 109. In order to obtain the stock prices, the applet needs to direct the browser 105 to, in turn, direct the operating system of the personal computer 104 to request a connection to a server process 110 running on the server computer. Once a connection has been established, the applet 106 then directs the browser to transmit one or more stock price database queries to the server process 110 which forwards the queries to the database management system 108. The database management system executes the queries against stock price data stored in the data storage device 107 in order to obtain the response stock price data, and then directs the server process 110 to transfer the response stock price data back to the applet 106. Finally, the applet directs the browser via the operating system of the personal computer to display the response stock price data in a stock price report on the display monitor. The data transfer between the personal computer and the server computer occurs through network controller hardware devices 111 and 112 over telephone lines, a local area network 113 or a wide area network. Additional controllers 114 and 115 mediate transfer of data from the personal computer to the display monitor of the personal computer and from the data storage device to the server operating system.
Because the applet is restricted in its ability to access resources, including the database management system, devising a general access strategy for accessing database management systems from an applet, as in the above example, has proved to be a difficult problem. There is, for example, no standard method for an applet to employ TCP/IP sockets in order to access remote database management systems. While access using TCP/IP is possible, a TCP/IP based server process would need to be developed to run on the server computers that contain the database management systems. Development of such a server process requires carefill attention to details involved in handling error conditions that arise because of network and database errors. In addition, careful attention would be required to considerations of the number of connections allowable on a server and to considerations of the practical limitations to connectivity arising from database management systems and from bandwidth limitations of the local area network or telephone lines by which data is transferred. Another possible method is the JDBC-ODBC bridge. JDBC was developed for JAVA and allows JAVA applets to access a database management system using a driver written in JAVA for each particular type of database management system. This method has the drawback that development of the drivers can be quite difficult, code writing and debugging under JDBC can be complex, additional software needs to be added to the personal computer that uses native calls that are not compatible with all browsers, and the applet must adhere to a number of security requirements. Because applets have relatively free access to HTML pages unconstrained by security requirements, a third method might employ placing the stock price data into HTML pages rather than into a database management system, so that the applet could access the data directly. The disadvantage in this method is that storing the stock price data in static HTML pages can be quite inefficient, and data stored in this manner is not amenable to incremental updates and easy and efficient ad hoc searching and manipulation. A need has therefore been recognized for a technique that allows an applet running on a client computer to easily access a database management system running on a server computer.
An embodiment of the present invention provides a method and system for accessing a database management system running on a server computer from within a JAVA applet running on a client computer. The JAVA applet prepares a uniform resource locator (xe2x80x9cURLxe2x80x9d) with which to address an active server page on the server computer, embedding within the URL a database query. The JAVA applet then accesses the active server page using the prepared URL as an address in the same way that the JAVA applet would access a HTML page. Upon receiving the request for access to the active server page, the server computer executes a script stored within the active server page that receives from the server computer the database query embedded within the URL, passes the database query to the database management system, receives from the database management system the query results, creates. a HTML document, and stores. the query results in the HTML document. The server computer then returns the HTML document to the client computer, where the JAVA applet opens the returned HTML document and reads the query results from the HTML document in the same manner as the JAVA applet would open and read data from a text file.